package com.example.pattern.command;

/**
 * 应用
 *
 * @author FM_南风
 * @date 2024/7/5
 */
public class CommandClient {
    public static void main(String[] args) {
        // 创建灯对象
        Light light = new Light();

        // 创建具体命令对象
        Command turnOnCommand = new LightOnCommand(light);
        Command turnOffCommand = new LightOffCommand(light);

        // 创建遥控器对象
        RemoteControl remoteControl = new RemoteControl();

        // 设置命令并执行
        remoteControl.setCommand(turnOnCommand);
        remoteControl.pressButton(); // 打开灯

        remoteControl.setCommand(turnOffCommand);
        remoteControl.pressButton(); // 关闭灯
    }
}
